#ifndef CONFIG_H
#define CONFIG_H



#ifdef LOGDEBUG
    #define debug(fmt, ...)   printf("[%s:%d %s]: " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif


/*
 * Handler function for ini_parse()
 * @param user User data pointer
 * @param section Section name
 * @param name Option name
 * @param value Option value
 * @note The value string is not null-terminated, it may contain null characters
*/
typedef void (*ini_handler)(void*,const char*,const char*,char*);

typedef struct string{ 
    char *str;
    size_t len;
    size_t cap;
}string;

void trim(char *str);



char *strdup (const char *__s) __attribute__((weak));
char *strtok_r(char *s, const char *delim, char **save_ptr) __attribute__((weak));


char **str_split(char *input,char *delim,int buf_size);
int str_has_suffix(const char *str, const char *suffix);
void str_neat(char *input);
char *str_merge(const char *str,const char *append);
char * str_merge_n( const char *str,...);
void str_free(char **str);

char **load_dir(const char *path,const char *suffix);
void split_dir_file(char *dir,char *file,const char *filepath);

int ini_parse(void* user,const char *path,ini_handler handle,long *mtime);
int ini_mmap_parse(void *user, const char *path, ini_handler handler, long *mtime);

char **listFiles_fromDir_suffix(const char *dirname,const char *suffix);
char **listFilesPath_fromDir_multiSuffix(const char *dir,const char *multi_suffix);
/**string函数*/

string string_from(char *str);
string string_clone(const string s);
string string_append(string s,...);
string string_append_str(string s,const char *str);
string * string_split(const string s, const string dilm);
void string_clean(string *s);
void string_free(string *s);
#endif
